"use client" //一定要先标注这个
import { createContext, useContext } from "react";

type Theme = {
    colors: {
        primary: string,
        secondary: string
    }
}
const defaultTheme = {
    colors: {
        primary: "red",
        secondary: "pink"
    }
}

const ThemeContext = createContext<Theme>(defaultTheme);

export const ThemeProvider = ({ children }: { children: React.ReactNode }) => {
    return (
        // react 19以前是<ThemeContext.Provider>
        <ThemeContext value={defaultTheme}>
            {children}
        </ThemeContext>
    )
}

// 再提供一个useTheme给其他的client组件使用
export const useTheme = () => useContext(ThemeContext);